package com.example.presentshopping.ui.fragment.frgmentdlog

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.example.presentshopping.R
import com.example.presentshopping.config.base.BaseFragmentDialog
import com.example.presentshopping.ui.activity.TurntableAddressActivity
import com.example.presentshopping.ui.activity.TurntableResActivity
import com.example.presentshopping.ui.custom.Prize
import com.example.presentshopping.utils.glide.GlideUtil
import com.example.presentshopping.utils.tool.unit.DimenUtil

class WinningDialog(var sta: Prize) : BaseFragmentDialog() {
    //调整窗口样式
    override fun onStart() {
        super.onStart()
        // 弹框添加。
        val dialog = dialog
        if (dialog != null && activity != null) {
            //设置窗口的背景
            dialog.window!!.setBackgroundDrawableResource(android.R.color.transparent)
            val lp = dialog.window!!.attributes
            lp.dimAmount = 0.8f //设置窗口后面的暗度
            // lp.alpha = 0.8f;//设置dialog窗口的透明度
            //设置dialog窗口的宽
            lp.width = ((DimenUtil.getScreenWidth() * 0.95f).toInt())
            lp.height = ((DimenUtil.getScreenHeight()*0.45).toInt())//设置dialog窗口的高
            dialog.window!!.attributes = lp
        }
    }
    override fun initView(view: View?, savedInstanceState: Bundle?) {
        val sin_wnin = view?.findViewById<ImageView>(R.id.sin_wnin)
        val odse_tc = view?.findViewById<TextView>(R.id.odse_tc)
        val  bu_inw = view?.findViewById<Button>(R.id.bu_inw)
        odse_tc?.text = sta.name
        sin_wnin?.setImageBitmap(sta.icon)

        bu_inw?.setOnClickListener {
            startActivity(Intent(context,
                TurntableResActivity().javaClass))
        }
    }

    override val layoutId: Int
        get() = R.layout.winning_dialog
}